package com.iflytek.autofly.setting.biz.base;

import android.view.View;

import com.iflytek.autofly.setting.R;
import com.iflytek.autofly.setting.widget.SpRadioButton;

/**
 * <b>Description: </b>TODO<br/>
 * <b>Change History:</b><br/>
 * <table border="1">
 * <tr>
 * <td><b>user</b></td>
 * <td><b>date</b></td>
 * <td><b>time</b></td>
 * <td><b>reason</b></td>
 * </tr>
 * <tr>
 * <td>JunLuan@iflytek.com</td>
 * <td>2015/11/20</td>
 * <td>16:41</td>
 * <td>创建此文件</td>
 * </tr>
 * </table>
 *
 * @author JunLuan@iflytek.com
 */
public class CommonRadioButtonHolder extends SpAdprViewHolder {

    SpRadioButton spRadioButton;

    @Override
    public void initView(View v) {
        spRadioButton = (SpRadioButton) v.findViewById(R.id.sp_radio_button);
    }

    @Override
    public void updateView(SpAdptBean b) {
        CommonRadioButtonBean bean = (CommonRadioButtonBean) b;
        spRadioButton.setText(bean.getText());
        spRadioButton.setDesc(bean.getDesc());
    }

    @Override
    public SpAdprViewHolder newInstance() {
        return new CommonRadioButtonHolder();
    }

    @Override
    public void setStatus(int status) {
        int id = 0;
        switch (status) {
            // normal
            case 0:
                id = R.drawable.radio_btn_normal;
                break;
            // enabling
            case 1:
                id = R.drawable.radio_btn_checking;
                break;
            // enabled
            case 2:
                id = R.drawable.radio_btn_checked;
                break;
        }
        if (id != 0) {
            spRadioButton.mRadioButton.setButtonDrawable(id);
        }
    }
}
